
interface TreeNode<T> {
    children?: TreeNode<T>[];
  }
function treeToFlat<T>(treeData: TreeNode<T>): T[] {
    const target: T[] = []
    function treeTransFlat(treeData: TreeNode<T>, target: T[] = []) {
        if (Array.isArray(treeData)) {
            for (const item of treeData) {
                if (item.children) {
                    treeTransFlat(item.children, target)
                }
                item.children = null
                target.push(item)
            }
        }
        return target
    }
    const flatArr = treeTransFlat(treeData, target)
    return flatArr
}


export {
    treeToFlat
}